package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getMethod("say", String.class,int.class);

        String name = method.getName();
        System.out.println(name);

        Class returnType = method.getReturnType();
        System.out.println(returnType);

        int count = method.getParameterCount();
        System.out.println(count);

        Class[] types = method.getParameterTypes();
        for (Class type:types){
            System.out.println(type);
        }


        int modfiers = method.getModifiers();
        switch (modfiers){
            case Modifier.PUBLIC:
                System.out.println("是一个公开方法");
                break;
            case Modifier.PRIVATE:
                System.out.println("是一个私有方法");
                break;
            case Modifier.PROTECTED:
                System.out.println("是一个受保护的方法");
                break;
        }
    }
}
